package com.itheima.hashsetdemo;

import java.util.HashSet;
import java.util.Iterator;

public class HashSetDemo {
    public static void main(String[] args) {
        HashSet<String> hs = new HashSet<>();
        hs.add("java");
        hs.add("java");
        hs.add("hello");
        hs.add("world");

        Iterator<String> iterator = hs.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println("--------------------");
        for (String h : hs) {
            System.out.println(h);
        }
    }
}
